package uid.elements;

import java.util.ArrayList;
import java.util.List;

public class OutputDataItem extends DataItem {

	private boolean optional = false;
	protected List<Transition> listTransitions;

	public OutputDataItem(String name) {
		super(name);
		this.listTransitions = new ArrayList<Transition>();
	}

	public OutputDataItem(String name, String domain) {
		super(name, domain);
		this.listTransitions = new ArrayList<Transition>();
	}

	public List getTransitions() {
		return this.listTransitions;
	}

	public void insertTransition(Transition transition) {
		for (int i = 0; i < this.listTransitions.size(); i++) {
			Transition trans = this.listTransitions.get(i);
			if (trans.getId().equals(transition.getId()))
				throw new UIDException(UIDException.EXISTING_TRANSITION,
						"There is already a transition with this id");
		}
		this.listTransitions.add(transition);
	}

	public void setOptional(boolean optional) {
		this.optional = optional;
	}

	public boolean isOptional() {
		return optional;
	}
}
